VERSION 4.00
Begin VB.Form DLPage 
   Appearance      =   0  'Flat
   AutoRedraw      =   -1  'True
   BackColor       =   &H00000000&
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "Retreiving Page"
   ClientHeight    =   720
   ClientLeft      =   2085
   ClientTop       =   5340
   ClientWidth     =   4680
   Height          =   1185
   Left            =   1995
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   720
   ScaleWidth      =   4680
   Top             =   4965
   Visible         =   0   'False
   Width           =   4860
   Begin VB.PictureBox Logo 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H00000000&
      FillStyle       =   0  'Solid
      ForeColor       =   &H80000008&
      Height          =   450
      Left            =   120
      Negotiate       =   -1  'True
      ScaleHeight     =   420
      ScaleWidth      =   420
      TabIndex        =   2
      Top             =   120
      Width           =   450
      Begin VB.Timer tmrLogo 
         Interval        =   250
         Left            =   240
         Top             =   -180
      End
   End
   Begin VB.Timer tmrDL 
      Left            =   4080
      Top             =   0
   End
   Begin VB.Label lblSavingTo 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Saving Data To:"
      ForeColor       =   &H0000FF00&
      Height          =   195
      Left            =   840
      TabIndex        =   6
      Top             =   480
      Width           =   1170
   End
   Begin VB.Label FileName 
      Caption         =   "FileName"
      Height          =   255
      Left            =   1200
      TabIndex        =   5
      Top             =   0
      Visible         =   0   'False
      Width           =   735
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   3480
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   26
      ImageHeight     =   26
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   11
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":0000
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":0730
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":0E60
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":1590
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":1CC0
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":23F0
            Key             =   ""
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":2B20
            Key             =   ""
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":3250
            Key             =   ""
         EndProperty
         BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":3980
            Key             =   ""
         EndProperty
         BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":40B0
            Key             =   ""
         EndProperty
         BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "DLWebPage.frx":47E0
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Label GetURL 
      Caption         =   "GetURL"
      Height          =   255
      Left            =   2040
      TabIndex        =   4
      Top             =   0
      Visible         =   0   'False
      Width           =   735
   End
   Begin VB.Label Action 
      Caption         =   "Action"
      Height          =   255
      Left            =   2880
      TabIndex        =   3
      Top             =   0
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.Label lblBytes 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Bytes Downloaded So Far...."
      ForeColor       =   &H0000FFFF&
      Height          =   195
      Left            =   840
      TabIndex        =   1
      Top             =   240
      Width           =   2025
   End
   Begin VB.Label lblRetrieve 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Retrieving:  Stand By...."
      ForeColor       =   &H0000FFFF&
      Height          =   195
      Left            =   840
      TabIndex        =   0
      Top             =   0
      Width           =   1680
   End
End
Attribute VB_Name = "DLPage"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit

Dim CurrentLogo As Long

'<meta HTTP-EQUIV="Refresh" CONTENT="

' Win32 Internet function: InternetOpen
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long

' Win32 Internet function: InternetOpenUrl
Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" _
(ByVal hOpen As Long, ByVal sUrl As String, ByVal sHeaders As String, _
ByVal lLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long

' Win32 Internet function: InternetReadFile
Private Declare Function InternetReadFile Lib "wininet.dll" _
(ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) As Integer

' Win32 Internet function: InternetCloseHandle
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Long) As Integer

Private Const scUserAgent = "VB OpenUrl"
' Use registry access settings.
Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Private Const INTERNET_FLAG_RELOAD = &H80000000
Private Const INTERNET_FLAG_SECURE = &H800000

Sub GetDataFrom(ByVal URL As String, ByVal OutputFile As String)
Me.Caption = "Retrieving " & URL
lblBytes.Caption = "0 Bytes Downloaded So Far...."
lblRetrieve.Caption = "Retrieving data from " & URL & "..."
logo.Picture = LoadPicture(App.Path & "/logo/1.bmp")

tmrLogo.Enabled = True
On Error Resume Next
    Dim hOpen               As Long
    Dim hOpenUrl            As Long
    Dim sUrl                As String
    Dim bDoLoop             As Boolean
    Dim bRet                As Boolean
    Dim sReadBuffer         As String * 10 '2048
    Dim lNumberOfBytesRead  As Long
    Dim sBuffer             As String
    
    sUrl = URL
    lblRetrieve.Caption = "Getting " & sUrl
    
    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    If hOpen = 0 Then
        lblRetrieve.Caption = "Error: " & Err.LastDllError
        Exit Sub
    Else
        lblRetrieve.Caption = "Opening Connection to " & sUrl & "..."
    End If
    
    hOpenUrl = InternetOpenUrl(hOpen, sUrl, vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
    If hOpenUrl = 0 Then
        lblRetrieve.Caption = "Error: " & Err.LastDllError
        Exit Sub
    Else
        lblRetrieve.Caption = "Preparing to download data from " & sUrl & "..."
    End If
    
    Dim StrToPut As String
    StrToPut = ""
    
    bDoLoop = True
    While bDoLoop
        sReadBuffer = vbNullString
        bRet = InternetReadFile(hOpenUrl, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
       If bRet = 0 Then
            lblRetrieve.Caption = "Error: " & Err.LastDllError
            Exit Sub
        Else
            lblRetrieve.Caption = "Downloading " & sUrl & "..."
            lblBytes = lNumberOfBytesRead & " bytes downloaded so far..."
        End If
        
        StrToPut = StrToPut & sReadBuffer
        sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
        tmrLogo.Enabled = True
        If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
    Wend
    
'Done with download
    lblRetrieve.Caption = "Finished Downloading " & sUrl
    
    On Error Resume Next
    On Error GoTo 0
    
'    If Dir("C:\Temp\log.txt") <> "" Then Kill "C:\Temp\log.txt"
    
    Open OutputFile For Output As #1
        Print #1, StrToPut
    Close #1
    
    If hOpenUrl <> 0 Then InternetCloseHandle (hOpenUrl)
    If hOpen <> 0 Then InternetCloseHandle (hOpen)
    
    Dim Prog As String
    If Action = "ViewSource" Then
        Prog = Shell("Notepad.exe " & App.Path & "\Source.txt", 1)
    End If
    
    Unload DLPage
'    rt.filename = "C:\Temp\log.txt"
End Sub



Private Sub filename_Change()
lblSavingTo.Caption = "Saving Data To: " & filename.Caption
End Sub

Private Sub Form_Load()
'How to use
' Make form visible by DLPage.visible = True
' Next: Set DLPage.GetURL to the URL you want to download

 SetWindowPos Me.hWnd, HWND_TOPMOST, Me.Left / 15, _
     Me.Top / 15, Me.Width / 15, _
     Me.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW

CurrentLogo = 1

tmrLogo.Enabled = True
tmrLogo.Interval = Window.tmrLogo.Interval

End Sub







Private Sub geturl_Change()
GetDataFrom geturl.Caption, filename.Caption

End Sub

Private Sub tmrLogo_Timer()
On Error GoTo ErrorHandler:
Dim LogoInterval As Integer

logo.Picture = ImageList1.ListImages(CurrentLogo).Picture

CurrentLogo = CurrentLogo + 1
If CurrentLogo >= 12 Then CurrentLogo = 1

ErrorHandler:
    If Err.Number = 53 Then
        CurrentLogo = 0
        Resume Next
    End If
End Sub


